import QtQuick 2.15
import QtQuick.Controls 2.15
import QtQuick.Layouts 2.15
import '../component'

ToolBar {
	width: parent.width
	Layout.fillWidth: true
	height: 32
	background: Rectangle {
		color: Qt.color('#DD1D56') // 设置为透明色
	}
	RowLayout {
		anchors.fill: parent
		MusicToolButton {
			source: "qrc:/resources/icon/music.png"
			toolTip: '关于'
			onClicked:{
				aboutPop.open()
			}
		}
		MusicToolButton {
			source: "qrc:/resources/icon/about.png"
			toolTip: 'shenjianZ'
			onClicked:{
				Qt.openUrlExternally('https://blog.shenjianl.cn')
			}
		}
		MusicToolButton {
			id: smallWindowButton
			source: "qrc:/resources/icon/small-window.png"
			toolTip: '小窗播放'
			onClicked: {
				window.width = window.smallWindowWidth
				window.height = window.smallWindowHeight
				window.x = (Screen.desktopAvailableWidth - window.width) / 2
				window.y = (Screen.desktopAvailableHeight - window.height) / 2
				smallWindowButton.visible = false
				normalWindowButton.visible = true
			}
		}
		MusicToolButton {
			id: normalWindowButton
			source: "qrc:/resources/icon/exit-small-window.png"
			visible: false
			toolTip: '退出小窗'
			onClicked: {
				window.width = window.normalWindowWidth
				window.height = window.normalWindowHeight
				window.x = (Screen.desktopAvailableWidth - window.width) / 2
				window.y = (Screen.desktopAvailableHeight - window.height) / 2
				smallWindowButton.visible = true
				normalWindowButton.visible = false
			}
		}
		Item {
			Layout.fillWidth: true
			height: 32
			Text {
				anchors.centerIn: parent
				text: qsTr("shenjianZ")
				font.family: window.fontFamily
				font.pointSize: 15
				color: Qt.color('#FFFFFF')
			}
		}
		MusicToolButton {
			source: "qrc:/resources/icon/minimize-screen.png"
			toolTip: '最小化'
			onClicked:{
				window.hide()
			}
		}
		MusicToolButton {
			id:maxWindow
			source: "qrc:/resources/icon/full-screen.png"
			toolTip: '全屏'
			onClicked:{
				window.visibility = Window.Maximized
				maxWindow.visible = false
				resize.visible = true
			}
		}
		MusicToolButton {
			id:resize
			source: "qrc:/resources/icon/small-screen.png"
			toolTip: '退出全屏'
			visible:false
			onClicked:{
				window.visibility = Window.AutomaticVisibility
				window.width = window.normalWindowWidth
				window.height = window.normalWindowHeight
				window.x = (Screen.desktopAvailableWidth - window.width) / 2
				window.y = (Screen.desktopAvailableHeight - window.height) / 2
				maxWindow.visible = true
				resize.visible = false
			}
		}
		MusicToolButton {
			source: "qrc:/resources/icon/power.png"
			toolTip: '退出'
			onClicked:{
				Qt.quit()
			}
		}
	}
	Popup{
		id:aboutPop
		parent: Overlay.overlay
		x:(parent.width - width )/2
		y:(parent.height - height )/2
		width:250
		height:230
		rightInset:-10
		leftInset:-10
		background:Rectangle{
			color:Qt.color('#E9F4FF')
			radius: 5
			border.color:Qt.color('#2273A7AB')
		}
		
		contentItem:ColumnLayout{
			width:parent.width
			height:parent.height
			Image{
				source: 'https://blog.shenjianl.cn/aisi-coding/logo.svg'
				Layout.preferredWidth:60
				Layout.fillWidth:true
				fillMode:Image.PreserveAspectFit
			}
			Text{
				text:qsTr('MusicPlayer,一个云上音乐播放器')
				font.pixelSize: 16
				color:Qt.color('#8573A7AB')
				font.family: '楷体'
				font.bold: true
				horizontalAlignment:Text.AlignHCenter
				Layout.fillWidth:true
			}
			Text{
				text:qsTr('https://blog.shenjianl.cn')
				font.pixelSize: 15
				color:Qt.color('#8573A7AB')
				font.family: '楷体'
				font.bold: true
				horizontalAlignment:Text.AlignHCenter
				Layout.fillWidth:true
			}
		}
		
		
	}
}
